package tcu.iot.mqttupdate.dao;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;
import tcu.iot.mqttupdate.entity.MQTTReturn;

import java.util.List;

@Mapper
@Component("MQTTMapper")
@Repository
public interface MQTTMapper {

    @Insert("INSERT INTO MQTT (device,time,template,power,I1,I2,I3,I4) VALUES (#{device},#{time}, #{template}, #{power}, #{I1}, #{I2}, #{I3}, #{I4})")
    void InsertData(String device, String time, String template, int power, double I1, double I2, double I3, double I4);

    @Select("SELECT * FROM MQTT WHERE device=#{device}")
    List<MQTTReturn> SelectData(String deviceName);

    @Delete("DELETE FROM MQTT WHERE template=#{template}")
    boolean DeleteData(String template);

    @Select("SELECT * FROM connectMqtt")
    List<String> connectMqtt();
}
